package com.letv.so.service.impl;

import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.transport.TMemoryBuffer;
import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;

import serving.ResultDocInfo;

import net.rubyeye.xmemcached.transcoders.BaseSerializingTranscoder;
import net.rubyeye.xmemcached.transcoders.CachedData;
import net.rubyeye.xmemcached.transcoders.Transcoder;

public class ResultDocInfoTranscoder extends BaseSerializingTranscoder implements Transcoder<ResultDocInfo> {

    private Logger logger = org.slf4j.LoggerFactory.getLogger(ResultDocInfoTranscoder.class);
    
    @Override
    public CachedData encode(ResultDocInfo paramT) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public ResultDocInfo decode(CachedData paramCachedData) {
        byte[] bytes = paramCachedData.getData();
        if (bytes==null || bytes.length == 0) {
            return null;
        }
        logger.warn("Bytes lenth:"+bytes.length);
        ResultDocInfo docInfo = new ResultDocInfo();
        TMemoryBuffer memBuf = new TMemoryBuffer(bytes.length);
        try {
          memBuf.write(bytes);
        }catch (TTransportException e1) {
            logger.error("pars error,",e1);
        }
        TBinaryProtocol binProto = new TBinaryProtocol(memBuf);
        try {
            docInfo.read(binProto);
        }catch(Exception e) {
            logger.error("pars error,",e);
        }
        return docInfo;
    }

    @Override
    public void setPrimitiveAsString(boolean paramBoolean) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public void setPackZeros(boolean paramBoolean) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public boolean isPrimitiveAsString() {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public boolean isPackZeros() {
        // TODO Auto-generated method stub
        return false;
    }

}
